package 全球变暖;

import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {
    static int N = 1010, total, bound, n;
    static char[][] g = new char[N][N];
    static boolean[][] st = new boolean[N][N];
    static int[] dx = {-1, 0, 1, 0};
    static int[] dy = {0, 1, 0, -1};

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        for (int i = 0; i < n; i++) {
            g[i] = in.next().toCharArray();
        }
        int cnt = 0;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (!st[i][j] && g[i][j] == '#') {
                    total = 0;
                    bound = 0;
                    bfs(new PII(i, j));
                    if (total == bound) {
                        cnt++;
                    }
                }
            }
        }
        System.out.println(cnt);
    }

    private static void bfs(PII start) {
        Queue<PII> q = new LinkedList<>();
        q.offer(start);
        st[start.x][start.y] = true;
        while (!q.isEmpty()) {
            PII t = q.poll();
            total++;
            boolean flag = false;
            for (int i = 0; i < 4; i++) {
                int a = dx[i] + t.x;
                int b = dy[i] + t.y;
                if (a < 0 || a >= n || b < 0 || b >= n) {
                    continue;
                }
                if (g[a][b] == '.') {
                    flag = true;
                    continue;
                }
                if (st[a][b]) {
                    continue;
                }
                st[a][b] = true;
                q.offer(new PII(a, b));
            }
            if (flag) {
                bound++;
            }
        }
    }
}

class PII {
    int x, y;

    public PII(int x, int y) {
        this.x = x;
        this.y = y;
    }
}
